#lang racket
(require "server.abstract.class.rkt")

(define launcher
  (class eserv%
    (inspect #f)
    (super-new)
    
    (define/override (on-msg _ msg __)
      (when (launch?  msg)
        (launch msg))
      empty-package)
    
    (define/public (launch? msg)
      (and (list? msg)
           (= 2 (length msg))
           (string? (first msg))
           (number? (second msg))))
    
    (define (launch msg)
      (let ([proc (process (first msg))])
        (thread (λ ()
                  (sleep (second msg))
                  ((last proc) 'kill)))))))

(define serv (make-server/effectful (new launcher)))
(send serv start)